import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    val:'',
    list:[],
    id:0
  },
  getters:{
    doing:state=>{
      return  state.list.filter(e =>!e.ischecked)
    },
    done:state=>{
      return  state.list.filter(e =>e.ischecked)
    }
  },
  mutations: {
    addlist(state,payload){
      if(payload==='')return
      
      const id=state.id++
      const Obj={id,ischecked:false,text:payload,edit:false}
      state.list.unshift(Obj)
     
      console.log(state.list);
    },
    deled(state,payload){
      if(!confirm("确定删除吗"))return
      const index=state.list.findIndex(e=>e.id===payload)
      state.list.splice(index,1)
    }
  

  },
  actions: {
  },
  modules: {
  }
})
